
//
//  InheritDemo.swift
//  Swift3.0_Study
//
//  Created by chengfeng on 2016/10/14.
//  Copyright © 2016年 zhaochengfeng. All rights reserved.
//

import Cocoa

enum Sex {
    case male, famale, unkonow
}

class InheritDemo: NSObject {
    
    class ClassA {
        var name: String?
        var sex: Sex?
        
        init() {
            
        }
        
        init(name: String?, sex: Sex?) {
            self.name = name;
            self.sex = sex;
        }
        
        func printInfo() -> Void {
            print("name = \(name), sex = \(sex)")
        }
    }
    
    class ClassB: ClassA {
        lazy var nickName: String? = {
            return self.name
        }()
        override func printInfo() {
            super.printInfo()
            print("nick name = \(self.nickName)")
        }
    }
    
    func start() -> Void {
        let a = ClassA(name: "chengfeng", sex: Sex.male)
        a.printInfo()

        let b = ClassB()
        b.printInfo()
        
    }

}
